package Java复习;

import java.util.*;

class Teacher{
    String sno;
    String name;
    int salary;
    public Teacher(String sno, String name, int salary) {
        this.sno = sno;
        this.name = name;
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "sno='" + sno + '\'' +
                ", name='" + name + '\'' +
                ", salary=" + salary +
                '}';
    }
}
public class gdq {
    public static void main(String[] args) {
      Teacher t1 = new Teacher("123", "zhangsan", 1000);
        Teacher t2 = new Teacher("124", "lisi", 1001);
        Teacher t3 = new Teacher("125", "wangwu", 1002);
        Teacher t4 = new Teacher("123", "hello", 1007);
        ArrayList<Teacher> list = new ArrayList<>();
        list.add(t1);
        list.add(t2);
        list.add(t3);
        list.add(t4);
        int s=0;
        int max=0;
        for (Teacher teacher : list) {
            s+=teacher.salary;
            if (teacher.salary>max)
                max = teacher.salary;
        }
        System.out.println(s);
        for (Teacher teacher : list) {
            if (teacher.salary==max)
                System.out.println(teacher);
        }
    }
}
